package com.gopay.bis.bos.ebank.impl;


import com.gopay.bis.bos.ebank.operation.BosB2cTransFormQuery;
import com.gopay.common.domain.bank.BaseMessage;
import com.gopay.common.domain.bank.bos.ebank.BosB2cMessage;
import com.gopay.common.exception.GopayException;
import com.gopay.remote.bank.ICertHelperBos;
import com.gopay.remote.bank.businesses.BankService;

public class BosB2cBankServiceImpl implements BankService {
	private ICertHelperBos bosB2cCerthelper;
	/** 订单查询实现类 */
	private BosB2cTransFormQuery bosB2cQuery;
	
	
	public Object sign(BaseMessage msg) throws GopayException {
		// B2C签名
		BosB2cMessage messageb2c = (BosB2cMessage) msg;
		String signMessage[] = bosB2cCerthelper.signReturnArray(messageb2c);
		if (signMessage != null && signMessage.length == 2) {
			messageb2c.setSignData(signMessage[0]);
			messageb2c.setKoalB64Cert(signMessage[1]);
		}
		return messageb2c;
	}

	public Object verify(BaseMessage msg) throws GopayException {
		boolean verifyResult = false;
		BosB2cMessage messageb2c = (BosB2cMessage) msg;
		verifyResult = (Boolean) bosB2cCerthelper.verify(messageb2c);
		return verifyResult;
	}

	public Object query(Object obj) throws GopayException {
		// B2C单笔订单查询
		BosB2cMessage messageb2c = (BosB2cMessage) obj;
	    return bosB2cQuery.query(messageb2c);
	}

	public void setBosB2cCerthelper(ICertHelperBos bosB2cCerthelper) {
		this.bosB2cCerthelper = bosB2cCerthelper;
	}

	public void setBosB2cQuery(BosB2cTransFormQuery bosB2cQuery) {
		this.bosB2cQuery = bosB2cQuery;
	}

	@Override
	public Object dayend(Object obj) throws GopayException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object refund(Object obj) throws GopayException {
		// TODO Auto-generated method stub
		return null;
	}

}
